package org.edu.modules.oa.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.edu.modules.oa.entity.VeOaMeetAnnounceEntity;
import org.edu.modules.oa.mapper.IVeOaCheckMeetAnnounceMapper;
import org.edu.modules.oa.service.IVeOaCheckMeetAnnounceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@Service
public class VeOaCheckMeetAnnounceServiceImpl implements IVeOaCheckMeetAnnounceService {
    @Resource
    private IVeOaCheckMeetAnnounceMapper iVeOaCheckMeetAnnounceMapper;


    @Override
    //通知查询-展示表格
    public HashMap<String, Object> showCheckMeetAnnounce(Integer page, Integer pageSize, VeOaMeetAnnounceEntity veOaMeetAnnounceEntity) {
        HashMap<String,Object> map = new HashMap<>();
        //创建分页的page
        IPage<VeOaMeetAnnounceEntity> checkMeetAnnouncePage = new Page<>(page,pageSize);
        //创建查询的条件，wrapper是条件综合器
        QueryWrapper<VeOaMeetAnnounceEntity>wrapper = new QueryWrapper<>();
        //前台传来的条件
        if(veOaMeetAnnounceEntity.getMeetName()!=null && veOaMeetAnnounceEntity.getMeetName()!="");{
            wrapper.like("meet_name",veOaMeetAnnounceEntity.getMeetName());
        }
        if(veOaMeetAnnounceEntity.getTitle()!=null && veOaMeetAnnounceEntity.getTitle()!=""){
            wrapper.like("title",veOaMeetAnnounceEntity.getTitle());
        }
        //mybatis plus的动态查询方法
        // 条件加上分页查询
        checkMeetAnnouncePage = iVeOaCheckMeetAnnounceMapper.selectPage(checkMeetAnnouncePage,wrapper);
        List<VeOaMeetAnnounceEntity>list = checkMeetAnnouncePage.getRecords();
        int count = iVeOaCheckMeetAnnounceMapper.selectCount(wrapper);
        // 把查出来的东西存到map里面去
        map.put("list",list);
        map.put("count",count);
        return map;
    }
}
